;(function(window, $) {
  var page1 = paging()
  $(function() {
    page1.init(1, 0, $('#page1'), function() {
      getList($(this).data('page'))
    })
    getList(1)
  })

  function getList(page) {
    //获取客户列表
    util.ajax({
      url: '/manager/customer/list?limit=6&page=' + page,
      type: 'POST',
      success: function(res) {
        page1.init(page, res.data.total)
        console.log(res)
        var custObj = res.data.rows
        $('.custom-list').empty()
        console.log(custObj)
        for (var i in custObj) {
          var aOuter = $('<a class="customer"></a>')
            .appendTo($('.custom-list'))
            .attr('href', 'customer.html?id=' + custObj[i].applyId)

          //中止申请
          var stopImg
          custObj[i].canceled == 1
            ? (stopImg = $(
                '<img src="http://img0.rongsue.com/images/channel/cancelApply.png" class="stopImg">'
              ).appendTo(aOuter))
            : (stopImg = $('<img class="stopImg">').appendTo(aOuter))

          var img = $('<img alt="" class="headshow">')
            .appendTo(aOuter)
            .attr('src', custObj[i].avatar)
          var div1 = $('<div class="custom-inf"></div>').appendTo(aOuter)
          var div2 = $(
            '<div href="javascript:;" class="layer"><div class="more">查看详情</div></div>'
          ).appendTo(aOuter)
          if (custObj[i].name == undefined) {
            var p1 = $('<p class="name"></p>')
              .html('--')
              .prependTo(div1)
          } else {
            var p1 = $('<p class="name"></p>')
              .html('（' + custObj[i].name + ')')
              .prependTo(div1)
          }
          var p2 = $('<p></p>')
            .html(custObj[i].instName + ' - ' + custObj[i].productName)
            .prependTo(div1)
        }
      }
    })
  }
})(window, jQuery)
